﻿using System;
using Runtime.DesignPattern;

namespace Plugins.FormicArch.Core
{
    public class FAEventSingleManager<KeyT> : GameSingleton<FAEventBaseManager<KeyT>>
    {
        // 注册事件（支持 1 到 5 个参数）
        public static void Register(KeyT eventType, object handler) =>
            Inst.RegisterHandler(eventType, handler);
        public static void Register(KeyT eventType, Action handler) =>
            Inst.RegisterHandler(eventType, handler);

        public static void Register<T>(KeyT eventType, Action<T> handler) =>
            Inst.RegisterHandler(eventType, handler);

        public static void Register<T1, T2>(KeyT eventType, Action<T1, T2> handler) =>
            Inst.RegisterHandler(eventType, handler);

        public static void Register<T1, T2, T3>(KeyT eventType, Action<T1, T2, T3> handler) =>
            Inst.RegisterHandler(eventType, handler);

        public static void Register<T1, T2, T3, T4>(KeyT eventType, Action<T1, T2, T3, T4> handler) =>
            Inst.RegisterHandler(eventType, handler);

        public static void Register<T1, T2, T3, T4, T5>(KeyT eventType, Action<T1, T2, T3, T4, T5> handler) =>
            Inst.RegisterHandler(eventType, handler);

        // 取消注册事件（支持 1 到 5 个参数）
        public static void Unregister(KeyT eventType, object handler) =>
            Inst.UnregisterHandler(eventType, handler);
        public static void Unregister(KeyT eventType, Action handler) =>
            Inst.UnregisterHandler(eventType, handler);
        public static void Unregister<T>(KeyT eventType, Action<T> handler) =>
            Inst.UnregisterHandler(eventType, handler);

        public static void Unregister<T1, T2>(KeyT eventType, Action<T1, T2> handler) =>
            Inst.UnregisterHandler(eventType, handler);

        public static void Unregister<T1, T2, T3>(KeyT eventType, Action<T1, T2, T3> handler) =>
            Inst.UnregisterHandler(eventType, handler);

        public static void Unregister<T1, T2, T3, T4>(KeyT eventType, Action<T1, T2, T3, T4> handler) =>
            Inst.UnregisterHandler(eventType, handler);

        public static void Unregister<T1, T2, T3, T4, T5>(KeyT eventType, Action<T1, T2, T3, T4, T5> handler) =>
            Inst.UnregisterHandler(eventType, handler);

        // 触发事件（支持 1 到 5 个参数）
        public static void Trigger(KeyT eventType) => Inst.TriggerHandler(eventType);
        public static void Trigger<T>(KeyT eventType, T arg) => Inst.TriggerHandler(eventType, arg);

        public static void Trigger<T1, T2>(
            KeyT eventType, 
            T1 arg1, 
            T2 arg2) =>
            Inst.TriggerHandler(eventType, arg1, arg2);

        public static void Trigger<T1, T2, T3>(KeyT eventType, T1 arg1, T2 arg2, T3 arg3) =>
            Inst.TriggerHandler(eventType, arg1, arg2, arg3);

        public static void Trigger<T1, T2, T3, T4>(
            KeyT eventType, 
            T1 arg1, 
            T2 arg2, 
            T3 arg3, 
            T4 arg4) =>
            Inst.TriggerHandler(eventType, arg1, arg2, arg3, arg4);


        public static void
            Trigger<T1, T2, T3, T4, T5>(
                KeyT eventType, 
                T1 arg1, 
                T2 arg2, 
                T3 arg3, 
                T4 arg4,
                T5 arg5) =>
            Inst.TriggerHandler(eventType, arg1, arg2, arg3, arg4, arg5);
    }
}